package com.cn.filter;

import org.noear.solon.annotation.Component;
import org.noear.solon.core.handle.Context;
import org.noear.solon.core.handle.Handler;
import org.noear.solon.core.route.RouterInterceptor;
import org.noear.solon.core.route.RouterInterceptorChain;

import java.util.ArrayList;
import java.util.List;

@Component
public class MyInterceptor implements RouterInterceptor {
    List<String> whiteList = new ArrayList<>();

    {
        whiteList.add("/swagger-resources");
        whiteList.add("/swagger/v2");
        whiteList.add("/doc.html");

    }

    @Override
    public void doIntercept(Context ctx, Handler mainHandler, RouterInterceptorChain chain) throws Throwable {
        String path = ctx.path();
        String host = ctx.header("Host");
        System.out.println(path);
        System.out.println(host);
        chain.doIntercept(ctx, mainHandler);
//        if (whiteList.contains(path)) {
//            chain.doIntercept(ctx, mainHandler);
//        } else if (path.equals("/h")) {
//            chain.doIntercept(ctx, mainHandler);
//        } else {
//            ctx.render("err msg");
//        }
    }
}